package com.skydonkey.dao;

import com.skydonkey.pojo.po.VideoActivity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface VideoActivityMapper {
    @Select("SELECT * FROM video_activity WHERE act_id = #{actId}")
    VideoActivity findById(int actId);

    @Insert("INSERT INTO video_activity (act_name, act_desc, act_create_time, act_start_time, act_end_time) " +
            "VALUES (#{actName}, #{actDesc}, #{actCreateTime}, #{actStartTime}, #{actEndTime})")
    @Options(useGeneratedKeys = true, keyProperty = "actId")
    void insert(VideoActivity videoActivity);

    @Update("UPDATE video_activity SET act_name = #{actName}, act_desc = #{actDesc}, " +
            "act_create_time = #{actCreateTime}, act_start_time = #{actStartTime}, act_end_time = #{actEndTime} " +
            "WHERE act_id = #{actId}")
    void update(VideoActivity videoActivity);

    @Delete("DELETE FROM video_activity WHERE act_id = #{actId}")
    void delete(int actId);

    @Select("SELECT * from video_activity")
    List<VideoActivity> selectAll();
}
